import axios from 'axios';
import {nanoid} from 'nanoid';
 export default{
    namespaced:true,
    actions:{
        addPersionServer(context){
            axios.get('https://api.uixsj.cn/hitokoto/get?type=social').then(value=>{
                context.commit('ADD_PERSON',{
                    id: nanoid(),
                    name: value.data
                })
            },reason=>{
                alert(reason.message)
            })
        }
    },
    mutations : {
        ADD_PERSON(state,value){
            state.personList.unshift(value);
        }
    },
    getters :{
        firstPersonName(state){
            return state.personList[0].name;
        }
    },
    state : {
        personList:[{"id":"001","name":"aaaa"}]
        
    }
}